<template>
	<view class="content">
		<view class="menuBox">
			<view class="menuItem" :class="menuIndex==index?'menuActive':''" v-for="(item,index) in menuArr"
				:key="index" @click="changeMenu(index)">
				{{item}}
			</view>
		</view>
		<!-- 	<view class="tabsBox">
			<v-tabs v-model="menuIndex" :tabs="['商品','课程']" bgColor="transparent" activeColor="#f08229"
				lineColor="#f08229" color="#00000" lineHeight='5rpx' @change="changeMenu()" class="vtabs"
				lineScale="0.6"></v-tabs>
		</view> -->
		<view class="tabsBox">
			<v-tabs v-model="menuIndex1" :tabs="['待评论','已评论']" bgColor="transparent" activeColor="#f08229"
				lineColor="#f08229" color="#00000" lineHeight='5rpx' @change="changeMenu1()" class="vtabs"
				lineScale="0.6"></v-tabs>
		</view>

		<!-- 商品 -->
		<scroll-view class="listBox" scroll-y="true" @scrolltolower="getMoreGoods()" v-if="menuIndex==0">
			<view class="listBoxInner">
				<view class="listItem" v-for="(item,index) in goods" :key="item.id">
					<image :src="item.goods_image" class="itemCover" />
					<text class="itemName">{{item.goods_name}}</text>
					<text class="toComment" v-if="menuIndex1==0"
						@click="$navto.navto('/user/comment/comment',{id:item.id,type:1,goods_id:item.goods_id,item_id:item.item_id})">去评价</text>
					<text class="line" v-if="index!=goods.length-1"></text>
				</view>
			</view>
		</scroll-view>

		<!-- 课程 -->
		<scroll-view class="popularCoursesList" v-else @scrolltolower="getMoreCourse()" scroll-y="true">
			<view class="popularCoursesItem" v-for="(item,index) in  course" :key="index">
				<image :src="item.course_snap.cover" class="popularCover"></image>
				<image :src="baseUrl+'tuwenIcon.png'" class="tuwenIcon" v-if="item.course_snap.type=='图文'" />
				<image :src="baseUrl+'videoIcon.png'" class="videoIcon" v-if="item.course_snap.type=='视频'" />
				<image :src="baseUrl+'voice.png'" class="orderIcon" v-if="item.course_snap.type=='音频'" />
				<image :src="baseUrl+'live.png'" class="liveIcon" v-if="item.course_snap.type=='直播'" />
				<text class="popularTitle">{{item.course_snap.name}}</text>
				<text class="toComment" @click="$navto.navto('/user/comment/comment',{id:item.id,type:2})">去评价</text>
				<text class="line" v-if="index!=course.length-1"></text>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		baseURL,
		basePath
	} from '@/config/app'
	export default {
		data() {
			return {
				menuArr: ['商品', '课程'],
				menuIndex: 0,
				menuIndex1: 0,
				baseUrl: `https://cdn.zkjialan.com/img/course/`,
				course: [],
				goods: [],
				page_no: 1,
			}
		},
		onShow() {
			this.getGoods();
			this.getCourse();
		},
		methods: {
			getGoods() {
				this.$request.get(`shopapi/goods_comment/commentGoodsLists?type=${this.menuIndex1}&page_no=1&page_size=15`)
					.then(res => {
						console.log(res.data);
						this.goods = res.data.data.lists;
					})
			},
			getMoreGoods() {
				this.page_no++;
				this.$request.get(`shopapi/goods_comment/commentGoodsLists?type=${this.menuIndex1}&page_no=${this.page_no}&page_size=15`).then(
					res => {
						this.goods.push(...res.data.data.lists);
					})
			},
			getCourse() {
				this.$request.get(`course/CourseComment/lists?page_no=1&page_size=10&is_comment=${this.menuIndex1}`).then(
					res => {
						console.log(res.data);
						this.course = res.data.data.lists;
					})
			},
			getMoreCourse() {
				this.page_no++;
				this.$request.get(`course/CourseComment/lists?page_no=${this.page_no}&page_size=10&is_comment=${this.menuIndex1}`).then(
					res => {
						this.course.push(...res.data.data.lists);
					})
			},
			changeMenu(index) { //商品 课程
				console.log('当前选中的项：' + index)
				this.page_no = 1;
				this.menuIndex1 = 0;
				this.menuIndex = index;
				if (index == 0) {
					this.getGoods();
				} else {
					this.getCourse();
				}
			},
			changeMenu1(index) { //已评论 待评论
				console.log('当前选中的项：' + index)
				this.page_no = 1;
				// if (index == 0) {
					if (this.menuIndex == 0) {
						this.getGoods();
					} else {
						this.getCourse();
					}
				// } else {
				// 	this.getCourse();
				// }
			}
		}
	}
</script>

<style lang="scss" scoped>
	.menuBox {
		width: 100%;
		height: 80rpx;
		background-color: #efefef;
		display: flex;

		.menuItem {
			width: 50%;
			height: 100%;
			font-size: 32rpx;
			font-family: 'ar';
			text-align: center;
			line-height: 80rpx;
		}

		.menuActive {
			background-color: #f08329;
			color: #fff;
		}
	}

	.line {
		width: 674rpx;
		height: 1rpx;
		background-color: #dcdcdc;
		margin-top: 70rpx;
	}

	.toComment {
		position: absolute;
		width: 128rpx;
		height: 50rpx;
		border-radius: 25rpx;
		background-color: #f08329;
		top: 128rpx;
		left: 320rpx;
		font-size: 22rpx;
		color: #fff;
		line-height: 50rpx;
		text-align: center;
		font-family: 'ar';
	}

	.listBox {
		position: relative;
		width: 670rpx;
		height: 80vh;
		/* margin-top: 290rpx; */
		margin-left: 40rpx;
		padding-top: 37rpx;
		overflow-y: scroll;

		// padding-bottom: 200rpx;
		.listBoxInner {
			width: 100%;
			// height: 65vh;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			overflow-y: scroll;

			.listItem {
				position: relative;
				width: 674rpx;
				border-radius: 15rpx;
				margin-bottom: 40rpx;
				background-color: #fff;

				.itemAdd {
					position: absolute;
					width: 36rpx;
					height: 36rpx;
					top: 290rpx;
					right: 30rpx;
				}

				.itemPrice {
					position: absolute;
					width: 300rpx;
					font-size: 23rpx;
					font-family: 'ar';
					color: #141414;
					top: 290rpx;
					left: 25rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}

				.itemCover {
					width: 270rpx;
					height: 177rpx;
					border-radius: 15rpx;
				}

				.itemName {
					position: absolute;
					font-size: 27rpx;
					color: #141414;
					top: 0;
					left: 320rpx;
					font-family: 'am';
					width: 250rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
			}
		}
	}


	.tabsBox {
		width: 60%;
		margin-left: 20%;
	}


	.popularCoursesList {
		width: 674rpx;
		height: 80vh;
		margin-left: 37rpx;
		margin-top: 65rpx;
		overflow-y: scroll;

		.liveTimeBox {
			position: absolute;
			top: 81rpx;
			left: 320rpx;
			display: flex;

			.liveTimeIcon {
				width: 21rpx;
				height: 21rpx;
			}

			.liveTime {
				font-size: 19rpx;
				color: #8e8e8e;
				margin-left: 15rpx;
			}
		}

		.liveTeacherBox {
			position: absolute;
			top: 47rpx;
			left: 320rpx;
			display: flex;

			.livePersonIcon {
				width: 21rpx;
				height: 20rpx;
			}

			.liveTeacherName {
				font-size: 19rpx;
				color: #8e8e8e;
				margin-left: 15rpx;
			}
		}

		.popularCoursesItem {
			position: relative;
			width: 674rpx;
			margin-bottom: 45rpx;

			.orderIcon,
			.liveIcon {
				position: absolute;
				width: 92rpx;
				height: 40rpx;
				top: 0rpx;
				left: 0;
			}

			.tuwenIcon,
			.videoIcon {
				position: absolute;
				width: 72rpx;
				height: 38rpx;
				top: 0rpx;
				left: 0;
			}

			.endBtn {
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #c8c8c8;
				top: 127rpx;
				right: 37rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
			}

			.learnBtn {
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #f08329;
				top: 127rpx;
				right: 37rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
			}


			.end {
				position: absolute;
				color: #8e8e8e;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.waitLive {
				position: absolute;
				color: #141414;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.popularPrice {
				position: absolute;
				color: #f08329;
				top: 140rpx;
				left: 320rpx;
				font-size: 28rpx;
				font-family: 'am';
			}

			.popularNumBox {
				position: absolute;
				width: 100%;
				height: 24rpx;
				left: 320rpx;
				top: 60rpx;
				display: flex;
				align-items: flex-start;

				.arrowIcon {
					width: 22rpx;
					height: 24rpx;
					margin-top: 5rpx;
				}

				.peopleLabel {
					font-size: 19rpx;
					color: #8e8e8e;
					margin-left: 15rpx;
					font-family: 'ar';
				}

				.line1 {
					width: 1rpx;
					height: 20rpx;
					margin-left: 30rpx;
					background-color: #dcdcdc;
					margin-top: 5rpx;
				}

				.timeIcon {
					width: 21rpx;
					height: 21rpx;
					margin-left: 30rpx;
					margin-top: 5rpx;
				}

				.popularTotal {
					font-size: 19rpx;
					color: #8e8e8e;
					margin-left: 15rpx;
					font-family: 'ar';
				}
			}

			.popularTitle {
				position: absolute;
				font-size: 27rpx;
				color: #141414;
				top: 0;
				left: 320rpx;
				font-family: 'am';
				width: 250rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.popularType {
				position: absolute;
				width: 68rpx;
				height: 37rpx;
				left: 0;
				top: 0;
			}

			.popularType1 {
				position: absolute;
				width: 73rpx;
				height: 37rpx;
				left: 0;
				top: 0;
			}

			.popularCover {
				width: 271rpx;
				height: 177rpx;
				border-radius: 20rpx;
			}
		}
	}

	/deep/.v-tabs__container {
		justify-content: space-between;
	}

	.vtabs {
		margin-top: 50rpx;
	}

	.content {
		position: fixed;
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		overflow-x: hidden;
		background-color: #fff;
	}

	page {
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		background-color: #fff !important;
		padding-bottom: 0 !important;
	}
</style>